<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<!-- 引入easyui的样式 -->	
<link rel="stylesheet"  type="text/css" href="${pageContext.request.contextPath}/themes/default/easyui.css">
<link rel="stylesheet"  type="text/css" href="${pageContext.request.contextPath}/themes/icon.css">
<link rel="stylesheet"  type="text/css" href="${pageContext.request.contextPath}/themes/bootstrap/layout.css">
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
<!-- js文件 -->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script type="text/javascript">
function editUser1(index,rid){
	$.ajax({
		  type:"post",
		  url: "SetLeave",
		  data:{
			  lid:rid
		  },
		  dateType:'text',
		  success: function(s){
			  $('#tb1').datagrid('reload');
		  }
	});
};
function editUser2(rid){
	var id=rid;
	$('#dd').dialog({    
	    title: '请填写不同意原因',   
	    width: 400,    
	    height: 200,    
	    closed: false,    
	    cache: false,    
	    modal: true   
	});
	$('#que').click(function(){
		alert($("#rs").val());
		$.ajax({
			  type:"post",
			  url: "SetNoReson",
			  data:{
				  lid:id,
				  noreson:$("#rs").val()
				  },
			  dateType:'text',
			  success: function(s){
				  $('#tb1').datagrid('reload');
				  $("#rs").val("");
				  $('#dd').dialog('close');
				  $("#rs").val("");
				  
				}
		});
	});

};
$(function () {
	function formatOper(val,row,index){
		var rid=row.lid;
	    return '&nbsp;&nbsp;<button type="button" class="btn btn-success" id="yes" onclick="editUser1('+index+','+rid+')">同意</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="button" class="btn btn-success" onclick="editUser2('+rid+')" id="no">不同意</button>';
	};
    $('#tb1').datagrid({  
        url:'GetNoApprove',  
        width: 1150,
        title: '待审批单',
        method:'post',
        columns: [[
			{ field: 'lid', title: '假单id', width: 100 },
            { field: 'cname', title: '班级', width: 100 },  
            { field: 'sname', title: '姓名', width: 100 },  
            { field: 'lnumber', title: '请假期间联系电话', width: 120 },
            { field: 'lreson', title: '请假原因', width:200 },
            { field: 'ldate', title: '请假时间', width:230 },
            { field: 'lapprove', title: '审批',formatter:formatOper, width:180 }
        ]],  
        rownumbers: true,
        pagination: true,
        pageSize:5,    
        pageList:[5,10,15]   
    });

}) ;
</script>
</head>
<body>
    <form id="form1" runat="server">  
	    <div>
		    <table id="tb1">
		    </table>
	    </div>  
    </form>
    <div id="dd" style="display:none;"> 
	    <textarea id="rs" ></textarea>
	    <input type="button" value="确定" id="que" >    
	</div>
</body>
</html>